package com.jcw.kqxt.service.impl;

import com.jcw.kqxt.constants.Constant;
import com.jcw.kqxt.domain.Dept;
import com.jcw.kqxt.domain.User;
import com.jcw.kqxt.mapper.UserMapper;
import com.jcw.kqxt.result.JSONResult;
import com.jcw.kqxt.service.IUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author qinhui
 * @since 2022-02-25
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    /**
     * 根据部门id查询用户
     */
    public JSONResult findUserByDeptId(Long id) {
        List<User> list = userMapper.findUserByDeptId(id);
        return JSONResult.success(list);
    }

    @Override
    public JSONResult deptDisable(Long id) {
        User user = super.selectById(id);
        user.setIsDelete(Constant.DEPT_IS_DELETE);
        super.updateById(user);
        return JSONResult.success();
    }
}
